package com.egao.texasHoldEmPoker.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.texasHoldEmPoker.mapper.PlayerJetonMapper;
import com.egao.texasHoldEmPoker.entity.PlayerJeton;
import com.egao.texasHoldEmPoker.service.PlayerJetonService;
import org.springframework.stereotype.Service;
import com.egao.texasHoldEmPoker.biz.PlayerJetonBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 下注服务实现类
 * @author : Doman
 * @date : 2022-01-26 12:21:48
 * @version ：1.0
 */
@Service
public class PlayerJetonServiceImpl /*extends ServiceImpl<PlayerJetonMapper, PlayerJeton> */implements PlayerJetonService {

	@Autowired
	private PlayerJetonBiz playerJetonBiz;

    /**
    @Override
    public PageResult<PlayerJeton> listPage(PageParam<PlayerJeton> page) {
        List<PlayerJeton> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<PlayerJeton> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, PlayerJeton playerJeton, User loginUser)  throws Exception{
        return playerJetonBiz.list(page,playerJeton,loginUser);
    }

    @Override
    public JsonResult list(PlayerJeton playerJeton, User loginUser) {
        return JsonResult.ok().setData(playerJetonBiz.list(playerJeton,loginUser));
    }

    @Override
    public JsonResult getById(PlayerJeton playerJeton) {
        return JsonResult.ok().setData(playerJetonBiz.getById(playerJeton));
    }

    @Transactional
    @Override
    public JsonResult save(PlayerJeton playerJeton, User loginUser) {
        if (playerJetonBiz.save(playerJeton, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(PlayerJeton playerJeton, User loginUser) {
        if (playerJetonBiz.update(playerJeton, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(PlayerJeton playerJeton, User loginUser) {
        if (playerJetonBiz.remove(playerJeton, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
